﻿using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using YiSha.Business.YiDongYuan;
using YiSha.Util.Extension;

namespace YiSha.Admin.WebApi.Controllers
{
    [ApiController]
    public class VInfoController : Controller
    {
        [Route("VInfo")]
        [HttpGet]
        public async Task<string> Index(string Brand)
        {
            var entity = await new DetectionMechanicsBLL().GetEntity(Brand);
            if (entity == null)
            {
                return "";
            }
            else
            {
                double kw = entity.Data.FDJGL.ParseToDouble(), accLimit = 1.0;
                switch (entity.Data.PFJD)
                {
                    case "国Ⅰ":
                    case "国Ⅱ":
                        if (kw < 19)
                            accLimit = 3.0;
                        else if (kw < 37)
                            accLimit = 2.0;
                        else
                            accLimit = 1.61;
                        break;

                    case "国Ⅲ":
                    case "国Ⅳ":
                    case "国Ⅴ":
                    case "国Ⅵ":
                        if (kw < 19)
                            accLimit = 2.0;
                        else if (kw < 37)
                            accLimit = 1.0;
                        else
                            accLimit = 0.80;
                        break;

                    default:
                        accLimit = 1.0;
                        break;
                }
                return $"{entity.Data.FDJGL}|{accLimit}|{entity.Data.FDJZS}|{entity.Data.FDJQGS}";
            }
        }
    }
}
